package com.mk.common.util;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.ObjectLoadException;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.mk.MyNutTestRunner;
import com.mk.common.entity.annotation.TreatCalcAnnotation;
import com.mk.common.service.CalcTreatFund;

@RunWith(MyNutTestRunner.class)
@IocBean
public class IocDemo
{
	@Inject
	Ioc ioc;
	
	@Test
	public void test1() {
		String arr[] = ioc.getNamesByAnnotation(TreatCalcAnnotation.class);
		for(String str: arr) {
			System.out.println(str);
		}
//		basicAllowanceCalc
//		heavyUseLessCalc
//		lowIncomeCalc
	}
	
	/**
	 * ×××
	 */
	@Test
	public void test5() {
		try {
			Class<?> clazz = ioc.getType("lowIncomeCalc");
			System.out.println(clazz);
		} catch (ObjectLoadException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Test
	public void test2() {
		String[] arr = ioc.getNamesByType(CalcTreatFund.class);
		for(String str: arr)
			System.out.println(str);
		
//		basicAllowanceCalc
//		heavyUseLessCalc
//		lowIncomeCalc
	}

	/**
	 * ××× 接口不准入
	 */
	@Test
	public void test3() {
		CalcTreatFund cla = ioc.get(CalcTreatFund.class);
		System.out.println(cla);
	}
	
	/**
	 * 第一个实现类
	 */
	@Test
	public void test4() {
		CalcTreatFund ca = ioc.getByType(CalcTreatFund.class);
		System.out.println("------------------------ 结果集  -------------------");
		System.out.println(ca);
		ca.calcFund();
	}
	
	
}
